package fg.animation;

public abstract class Animation {

	protected int duration = 0;

	public Animation(int duration) {
		this.duration = duration;
	}

	/**
	 * Should only be called by AnimationController class. Check if this
	 * Animation can continue, if it is so it calls animate(time).
	 * 
	 * @param time
	 * @return true if the animation is still running
	 */
	protected boolean continueAnimation(int time) {
		if (time > duration)
			return false;
		animate(time);
		return true;
	}

	/**
	 * Animates this animation in the specified time.
	 * 
	 * @param time
	 */
	public abstract void animate(int time);
	
	public abstract void reset();

	/**
	 * @return the duration
	 */
	public int getDuration() {
		return duration;
	}

	/**
	 * @param duration
	 *            the duration to set
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}

}
